<!DOCTYPE html>
<html lang="en">
<head>
    <script type="text/javascript" src="/static/Jquery.js"></script>
    <script type="text/javascript" src="/static/jquery-form.js"></script>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="form" key="registing" v-if="show">
    <form id="upload_form" action="register/noVerificationForExcel"
          enctype="multipart/form-data" method="post">
        <div class="form-group">
            <label class="col-sm-2 control-label">表格上传</label>
            <div class="col-sm-10">
                <input type="file" id="file" name="file" />
            </div>
        </div>
        <div class="form-group btn-box">
            <button type="button" class="btn btn-success btn-block bgc-color"
                    onclick="submitForm()">立即注册</button>
        </div>
    </form>

    <div class="success" key="registed" v-else v-cloak>
        <div class="success-img">
            <img src="static/img/right.png" alt="">
        </div>
        <div class="success-text">
            <p>恭喜注册成功</p>
            <p>即将跳转登录页面......</p>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function submitForm() {
        var excelPath = $("#file").val();
        if(excelPath == null || excelPath == ''){
            alert("请选择要上传的Excel文件");
            return;
        }else{
            var fileExtend = excelPath.substring(excelPath.lastIndexOf('.')).toLowerCase();
            if(fileExtend == '.xls' || fileExtend == '.xlsx'){
                $("#upload_form").ajaxSubmit({
                    url:"/poi/noVerificationForExcel",
                    cache:false,
                    dataType:'json',
                    success: function(data) {
                        alert(data.result);
                    } ,
                    error:function(){
                        alert(data.message);
                    }
                });
            } else {
                alert("文件格式需为'.xls'格式");
                return;
            }

        }


    }

</script>
</html>